﻿
var isShow = false;
function prepareShowData(data) {
    var datas = data;
    var yearCount = 0;

    var yeares=$('#comboboxYear').combobox('getText');
    var years= [];
    if(yeares!=null ||yeares!='' || yeares!=undefined){
        years=yeares.split(',');
    }
    if(years.length>1){
        years.sort(funcSort);
    }
    if (years != null && years != undefined) {
        yearCount = years.length;
    }
    var size = 0;
    if (datas != null) {
        size = datas.length;
    }
    zbname = [];
    series = [];
    jsonXData = [];
    conceal = {};
    // -------------------------------------------加绝对值指标---------------------------------------
    for (var i = 0; i < size; i++) {
        var aav = new Object();
        var aav2 = new Object(); // 加绝对值指标
        zbname.push(datas[i].iname);
        if (isTrue) { // 点击增长率出现
            zbname.push(datas[i].iname + '增长速度%');// 加绝对值指标
        }
        conceal[datas[i].iname + '增长速度%'] = false;
        aav.name = datas[i].iname;
        aav.type = 'bar';
        aav.barMaxWidth = 80;
        aav.label={normal: {show: true,position: 'top'}};
        var arr = [];
        aav2.name = datas[i].iname + '增长速度%';// 加绝对值指标
        aav2.type = 'line';// 加绝对值指标
        aav2.yAxisIndex = '1';
        aav2.label={normal: {show: true,position: 'top'}};
        var arr2 = [];// 加绝对值指标
        // 加绝对值指标---------------------------------------
        for (var j = 0; j < yearCount; j++) {
            if (datas[i][years[j]] != undefined) {
                if (j == 0) {
                    arr2.push(0);
                } else if (((datas[i][years[j]].split("_")[2] - datas[i][years[j - 1]].split("_")[2]) / datas[i][years[j - 1]].split("_")[2]) * 100 == Infinity) {
                    var avg = 0;
                    arr2.push(changeNum(avg));
                } else {
                    var avg = ((datas[i][years[j]].split("_")[2] - datas[i][years[j - 1]].split("_")[2]) / datas[i][years[j - 1]].split("_")[2]) * 100;
                    arr2.push(changeNum(avg));
                }
                arr.push(changeNum(datas[i][years[j]].split("_")[2]));
                jsonXData.push(years[j]);
            }
        }
        aav.data = arr;
        aav2.data = arr2;// 加绝对值指标
        series.push(aav);
        if (isTrue) {
            series.push(aav2); // 加绝对值指标
        }
    }

    if (data) {
        // 显示效果
        isShow = false;
        if (isTrue) {
            isShow = true;
        }
        showData(zbname, series, jsonXData, conceal, isShow);
    }
}
